<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<link rel="stylesheet" media="screen" type="text/css" href="__THEMES__/style/layout.css" />
		<script type="text/javascript" src="__JS__/jQuery/jquery.js"></script>
		<script type="text/javascript" src="__JS__/jQuery/plugin/troperate.js"></script>
		<script type="text/javascript" src="__JS__/jQuery/plugin/alertbox.js"></script>
		<include file="Public:js_artDialog" />
		<script type="text/javascript">
			$(function(){
				$('#add_model').click(function(){
					var pid = '{$_GET["pid"]}';
					if (pid != ''){
						var url = "__URL__/add/pid/"+pid;
					}else{
						var url = "__URL__/add/pid/0";
					}
					
					art.dialog.loadCall(url,{
						title : $(this).val(),
						lock : true
					}, false, function(){
						var ic = $('body',parent.document).find('#add_node_submit');
						ic.submit(function(){
							if ( ic.find('#name').val() == '' ){
								setAlertBox('模块名必须！', 2);
								ic.find('#name').addClass('errorInput').focus();
								return false;
							}
							if ( ic.find('#title').val() == '' ){
								setAlertBox('显示名称必须！', 2);
								ic.find('#title').addClass('errorInput').focus();
								return false;
							}
							$.post('__URL__/insert',ic.serialize(),function(c){
								setAlertBox(c.info, 2);
								if ( c.status === 0 ){
									return false;
								}else{
									window.location.reload();
								}
							},'json');
							return false;
						});
					});
				});
				
				$('.edit_model').click(function(){
					var url = $(this).attr('href');
					/*
					art.dialog.load(url,{
						title : $(this).val(),
						lock : true
					}, false);
					*/
					art.dialog.loadCall(url,{
						title : '编辑节点',
						lock : true
					}, false, function(){
						var ic = $('body',parent.document).find('#edit_node_submit');
						ic.submit(function(){
							if ( ic.find('#name').val() == '' ){
								setAlertBox('模块名必须！', 2);
								ic.find('#name').addClass('errorInput').focus();
								return false;
							}
							if ( ic.find('#title').val() == '' ){
								setAlertBox('显示名称必须！', 2);
								ic.find('#title').addClass('errorInput').focus();
								return false;
							}
							$.post('__URL__/update',ic.serialize(),function(c){
								setAlertBox(c.info, 2);
								if ( c.status === 0 ){
									return false;
								}else{
									window.location.reload();
								}
							},'json');
							return false;
						});
					});
					return false;
				});
				
				$('.del_node').click(function(){
					var del_url = $(this).attr('href');
					var _id = $(this).attr('rel');
					$.ajax({
						url : "__URL__/checkDelete/id/" + _id,
						dataType : "json",
						success : function(data){
							if (data.status == 0){
								setAlertBox(data.info, 2);
								return false;
							}else{
								art.dialog.confirm('确认删除操作？',function(){
									window.location.href = del_url;
								},function(){
									//取消操作回调
								});
							}
						},
						cache : false
					});
					return false;
				});
            });
		</script>
	</head>
	<body>
		
		<include file="Public:position" />
			
		<div class="button">
            <input type="button" value="新增节点" class="submit" id="add_model"  />
        </div>
                              
        <div class="a_table">
            <table cellspacing="1" width="100%" class="gr_list">
				<tr style="background: #f0f7ff; font-weight: bold;">
					<td width="60" align="center">编号</td>
					<td width="100" align="center">名称</td>
					<td align="center">显示名</td>
					<td width="100" align="center">分组</td>
					<td width="100" align="center">状态</td>
					<td width="160" align="center">操作</td>
				</tr>
				<volist id="vo" name="list">
				<tr rel="{$vo['id']}" class="row_color"<?php if( ( $i % 2 ) == 0 ){ ?> bgcolor="#f9f9f9"<?php } ?>>
					<td align="center">{$vo['id']}</td>
					<td align="center"><a href="{:U('index?pid='.$vo['id'].'&tag='.$_GET['tag'])}">{$vo['name']}</a></td>
					<td align="center">{$vo['title']}</td>
					<td align="center">{$vo['group_id']|getNodeGroupName}</td>
					<td align="center">{$vo['status']|getStatus}</td>
					<td align="center">
						{$vo['status']|showStatus=$vo['id'],'navTabAjaxMenu'}<span class="action_line">&nbsp;&nbsp;|&nbsp;&nbsp;</span><a href="{:U('edit?id='.$vo['id'].'&gid='.$vo['group_id'])}" class="edit_model">编辑</a><span class="action_line">&nbsp;&nbsp;|&nbsp;&nbsp;</span><a href="{:U('delete?id='.$vo['id'])}" class="del_node" rel="{$vo.id}">删除</a>
					</td>
				</tr>
				</volist>
			</table>
        </div>
	</body>
</html>